package com.itcast.manager3.D_dao;

import com.itcast.manager2.E_domain.Student;
import com.itcast.manager3.tomian.StudentTomain;

import javax.swing.plaf.synth.SynthTableUI;
import java.util.ArrayList;

public class StudentDao {
    private ArrayList<StudentTomain> list = new ArrayList<>();
    public void addStudent(StudentTomain stu) {
        list.add(stu);
    }

    public ArrayList<StudentTomain> getAllList() {
        return list;
    }

    public void deleteStendet(String id) {
        for (int i = 0; i < list.size(); i++) {
            StudentTomain stu = list.get(i);
            if (stu.getId().equals(id)){
                list.remove(stu);
            }
        }
    }

    public void updateStendt(StudentTomain stu) {
        for (int i = 0; i < list.size(); i++) {
            StudentTomain ss = list.get(i);
            if (ss.getId().equals(stu.getId())){
                ss.setName(stu.getName());
                ss.setAge(stu.getAge());
                ss.setBirthday(stu.getBirthday());
            }
        }
    }
}
